package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class LendOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书....");
        System.out.println("请输入想要借阅的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        //查找是否有
        int size = bookList.getSize();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getBook(i);
            if (name.equals(book.getName())) {
                bookList.getBook(i).setLend(true);
                System.out.println("借阅成功...");
                return;
            }
        }
        System.out.println("很抱歉，没有找到这本书...");
    }
}